/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author Administrator
 */
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class SendHTMLEmail
{
   public static void main(String [] args)
   {
      
      final String username = "prajja1990@gmail.com";
final String password = "amma2468524685";

Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");

Session session = Session.getInstance(props,
        new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password);
            }
        });

try {
    String name="PRAJWAL N";
    String emp = "0180826";
    String leave= "CL";
    String day="F";
    String fromdate="2015-01-01";
    String todate="2015-01-01";
    String body="not well";
    

    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress("prajja1990@gmail.com"));
    message.setRecipients(Message.RecipientType.TO,
            InternetAddress.parse("prajja1990@gmail.com"));
    message.setSubject("Test Subject");
 message.setContent(" <center> <table border='2'>\n"
                    + "  <tr> \n"
                    + "     <td>Leave Applied By :</td>\n"
                    + "           <td>" + name + "</td>\n"
                    + "  </tr>\n"
                    + "    <tr>\n"
                    + "        <td>Roll No :</td>\n"
                    + "           <td>" + emp + "</td>\n"
                    + "   </tr>\n"
                    + "   <tr>\n"
                    + "        <td>Leave Type :</td>\n"
                    + "           <td>" + leave + "</td>\n"
                    + "   </tr>\n"
                    + "   <tr>\n"
                    + "        <td>Leave Days :</td>\n"
                    + "           <td>" + day + "</td>\n"
                    + "   </tr>\n"
                    + "   <tr>\n"
                    + "        <td>Leave Period :</td>\n"
                    + "           <td>" + fromdate + " To " + todate + "</td>\n"
                    + "   </tr>\n"
                    + "   <tr>\n"
                    + "        <td>Reason :</td>\n"
                    + "           <td>" + body + "</td>\n"
                    + "   </tr>\n"
                    + "</table> <br> The above Leave is pending for your approval <br><br> <b>click on <U>192.9.201.243:82\\stars</u> for Lave/Regularization approval</b></center>",
                    "text/html");
           
  
System.out.println("Done");

    Transport.send(message);

    System.out.println("Done");

} catch (MessagingException e) {
    throw new RuntimeException(e);
}
   }
}
